package com.telecomyt.jwportal.activity.conference;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.activity.camera.bean.CameraBean;
import com.telecomyt.jwportal.activity.conference.adapter.ConferenceAdapter;
import com.telecomyt.jwportal.activity.conference.adapter.ConferenceBottomAdapter;
import com.telecomyt.jwportal.activity.conference.bean.ConferenceBottomBean;
import com.telecomyt.jwportal.base.BaseActivity;
import com.telecomyt.jwportal.utils.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 视频会议
 */
public class ConferenceActivity extends BaseActivity<ConferencePresenter> implements ConferenceContract.View {
    @BindView(R.id.mRecyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.mBottomRecyclerView)
    RecyclerView mBottomRecyclerView;
    private ConferenceAdapter conferenceAdapter;
    List<ConferenceBottomBean> listBeans = new ArrayList<>();
    private ConferenceBottomAdapter bottomAdapter;

    public static void start(Context context) {
        Intent starter = new Intent(context, ConferenceActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_conference;
    }

    @Override
    protected void initView() {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        conferenceAdapter = new ConferenceAdapter(R.layout.activity_conference_item);
        mRecyclerView.setAdapter(conferenceAdapter);
        conferenceAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Toast.makeText(ConferenceActivity.this, "点击了" + position, Toast.LENGTH_SHORT).show();
            }
        });
        mBottomRecyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
        bottomAdapter = new ConferenceBottomAdapter(R.layout.activity_conference_bottom_item, listBeans);
        mBottomRecyclerView.setAdapter(bottomAdapter);
        bottomAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                if (position == 4) {
                    finish();
                }
            }
        });
    }


    @Override
    protected void initData() {
//        persenter.getData(1);
        ConferenceBottomBean bottomBean = new ConferenceBottomBean();
        bottomBean.setIconPath(R.drawable.mic_normal);
        bottomBean.setTitle("录制");
        ConferenceBottomBean bottomBean1 = new ConferenceBottomBean();
        bottomBean1.setIconPath(R.drawable.icon_listener_normal);
        bottomBean1.setTitle("免提");
        ConferenceBottomBean bottomBean2 = new ConferenceBottomBean();
        bottomBean2.setIconPath(R.drawable.icon_audio_normal);
        bottomBean2.setTitle("静音");
        ConferenceBottomBean bottomBean3 = new ConferenceBottomBean();
        bottomBean3.setIconPath(R.drawable.icon_video_normal);
        bottomBean3.setTitle("关闭摄像头");
        ConferenceBottomBean bottomBean4 = new ConferenceBottomBean();
        bottomBean4.setIconPath(R.drawable.icon_hangup);
        bottomBean4.setTitle("挂断");
        ConferenceBottomBean bottomBean5 = new ConferenceBottomBean();
        bottomBean5.setIconPath(R.drawable.mic_normal);
        bottomBean5.setTitle("监控");
        ConferenceBottomBean bottomBean6 = new ConferenceBottomBean();
        bottomBean6.setIconPath(R.drawable.mic_normal);
        bottomBean6.setTitle("共享");
        ConferenceBottomBean bottomBean7 = new ConferenceBottomBean();
        bottomBean7.setIconPath(R.drawable.mic_normal);
        bottomBean7.setTitle("成员");
        ConferenceBottomBean bottomBean8 = new ConferenceBottomBean();
        bottomBean8.setIconPath(R.drawable.mic_normal);
        bottomBean8.setTitle("切换");
        ConferenceBottomBean bottomBean9 = new ConferenceBottomBean();
        bottomBean9.setIconPath(R.drawable.mic_normal);
        bottomBean9.setTitle("布局");
        listBeans.add(bottomBean);
        listBeans.add(bottomBean1);
        listBeans.add(bottomBean2);
        listBeans.add(bottomBean3);
        listBeans.add(bottomBean4);
        listBeans.add(bottomBean5);
        listBeans.add(bottomBean6);
        listBeans.add(bottomBean7);
        listBeans.add(bottomBean8);
        listBeans.add(bottomBean9);
        bottomAdapter.notifyDataSetChanged();

    }

    @Override
    protected ConferencePresenter creatPresenter() {
        return new ConferencePresenter(this);
    }


    @Override
    public void setData(CameraBean bean) {
        ToastUtils.showShort("请求数据成功");
        List<CameraBean.ResultBean> result = bean.getResult();
        if (result != null && result.size() > 0) {
            conferenceAdapter.setNewData(result);
        }
    }


}
